<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>共享车位</title>
    <link rel="stylesheet" href="mobile/layui/css/layui.mobile.css">
    <link rel="stylesheet" href="mobile/layui/css/layui.css">
    <link rel="stylesheet" href="mobile/css/yj_css.css">
    <link rel="stylesheet" href="mobile/css/iphoneX.css">
</head>
<body>
<header class="yj-header">
    <a class="yj-header-return layui-icon"></a>
    <span>首页</span>
    <a class="yj-header-meau"></a>
</header>
<footer class="yj-footer">
    <a class="yj-footer-item">
        <span class="yj-footer-icon"><img src="mobile/images/home2.png"></span>
        <p class="yj-footer-title yj-color-main">首页</p>
    </a>
    <a class="yj-footer-item yj-footer-middle" href="user.html">
        <span class="yj-footer-icon"><img src="mobile/images/user1.png"></span>
        <p class="yj-footer-title">个人中心</p>
    </a>
    <a class="yj-footer-item" href="order.html">
        <span class="yj-footer-icon"><img src="mobile/images/printer1.png"></span>
        <p class="yj-footer-title">订单详情</p>
    </a>
</footer>
<div class="yj-content">
    <!-- banner -->
    <link rel="stylesheet" href="mobile/css/swiper.min.css">
    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide"><img src="mobile/images/gongxiang.jpg" alt=""></div>
            <div class="swiper-slide"><img src="mobile/images/sayno.jpg" alt=""></div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
    </div>
    <script src="mobile/js/swiper.min.js"></script>
    <script>
        var swiper = new Swiper('.swiper-container', {
            loop:true,
            autoplay: {
                delay: 3000,
                disableOnInteraction: false,
            },
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            }
        });
    </script>
    <!-- banner end -->

    <!-- 普通title -->
    <!-- <p class="yj-title1 yj-mar-b yj-bgfff">包时随便印<a class="yj-right" href="#">more>></a></p> -->
    <!-- 商品列表 -->
    <ul class="yj-goods-list yj-clearfix"  id="carContent">


    </ul>

</div>
<a class="yj-contact" href="carIndex">
    <img src="mobile/images/map.png" >
</a>
<script th:src="@{/mobile/js/jquery.min.js}"></script>
<script src="mobile/layui/layui.js"></script>
<script th:inline="javascript">
    var url = [[@{/}]];
        layui.use("layer", function () {
            var layer = layui.layer;
        });
</script>
<script>
    $(document).ready(function () {
        $.ajax({
            url: url + "lessor/usefulcarpark",
            success:function (result) {
                var content = $("#carContent").text("");
                for (var i = 0; i <result.result.length ; i++) {
                    var carPark = result.result[i];
                    var test = "<li class=\"yj-goods-item\"><a class=\"yj-bgfff\" onclick='detail("+carPark.id +")' >\n" +
                        "        <img class=\"yj-goods-item-pic\" src="+carPark.cPic+" alt=\"\">\n" +
                        "        <p class=\"yj-elip-2 yj-goods-item-title\"><span class=\"yj-color-red\"></span>" + carPark.cAddress+ "</p>\n" +
                        "        <p class=\"yj-goods-list-footer yj-border-t\">\n" +
                        "          <span class=\"yj-goods-price\">&yen;" + carPark.cPrice+ "<small class=\"yj-text-small\">/小时</small></span>\n" +
                        "        </p>\n" +
                        "      </a></li>"
                    content.append(test);
                }
            }
        })
    })

        function detail(id) {
        $.ajax({
            url:url+"checkIdCard",
            success:function (result) {
                if (result.code == 200){
                    location.href ="goods_detail.html?id="+id;
                } else {
                    layer.confirm(result.msg, {
                        btn: ['前往','取消'] //按钮
                    }, function(){
                        location.href="user/authentication";
                    }, function(){

                    });
                }
            }
        })
    }
</script>

</body>

</html>